Skip to main content

BOJ 2577

2577 숫자의 개수

tip

Clicking the heading will take you to the BOJ problem.

Solution

a = int(input())
b = int(input())
c = int(input())

num = str(a * b * c)
count = [0] * 10

for n in num:
count[int(n)] += 1

for c in count:
print(c)

count()라는 파이썬 내장 메서드를 활용하여 풀 수도 있다. 문자열 안에서 특정 문자가 몇 번 등장하는지 세어준다.

a = int(input())
b = int(input())
c = int(input())

result = str(a * b * c)

for i in range(10):
    print(result.count(str(i)))